{extend name='common/_container'}
{block name="content"}
<div class="ibox float-e-margins">
	<div class="ibox-content">
		<div class="form-horizontal" id="CodeInfoForm">
			<div class="row">
				<div class="col-sm-12">
				<!-- form start -->
					<div class="form-group layui-form">
						<label class="col-sm-2 control-label">轮播图类型：</label>
						<div class="col-sm-9">
							<?php if(!isset($info['type'])){ $info['type'] = '1'; }; ?>
							<input name="type" value="1" type="radio" {if condition="$info.type eq '1'"}checked{/if} title="首页">
							<input name="type" value="0" type="radio" {if condition="$info.type eq '0'"}checked{/if} title="启动页">
                            <input name="type" value="2" type="radio" {if condition="$info.type eq '2'"}checked{/if} title="首页广告">

							<input name="type" value="3" type="radio" {if condition="$info.type eq '3'"}checked{/if} title="我的页面Banner(佳人)">
							<input name="type" value="5" type="radio" {if condition="$info.type eq '5'"}checked{/if} title="我的页面Banner(红娘)">

							<input name="type" value="4" type="radio" {if condition="$info.type eq '4'"}checked{/if} title="首页视频Banner">


						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">图片：</label>
						<div class="col-sm-6">
							<input type="text" autocomplete="off" id="image" value="" {if condition="config('my.img_show_status') eq true"}onmousemove="showBigPic(this.value)" onmouseout="closeimg()"{/if} name="image" class="form-control" placeholder="请输入图片">
							<span class="help-block m-b-none image_process"></span>
						</div>
						<div class="col-sm-2" style="position:relative; right:30px;">
							<span id="image_upload"></span>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">跳转链接：</label>
						<div class="col-sm-9">
							<input type="text" autocomplete="off" id="route" value="" name="route" class="form-control" placeholder="请输入跳转链接">
						</div>
					</div>
				<!-- form end -->
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<div class="row btn-group-m-t">
				<div class="col-sm-9 col-sm-offset-1">
					<button type="button" class="btn btn-primary" onclick="CodeInfoDlg.add()" id="ensure">
						<i class="fa fa-check"></i>&nbsp;确认提交
					</button>
					<button type="button" class="btn btn-danger" onclick="CodeInfoDlg.close()" id="cancel">
						<i class="fa fa-eraser"></i>&nbsp;取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<script src="__PUBLIC__/static/js/upload.js" charset="utf-8"></script>
<script src="__PUBLIC__/static/js/plugins/layui/layui.js" charset="utf-8"></script>
<script>
layui.use(['form'],function(){});
uploader('image_upload','image','image',false,'','{:getUploadServerUrl()}');
laydate.render({elem: '#createtime',type: 'datetime',trigger:'click'});
var CodeInfoDlg = {
	CodeInfoData: {},
	validateFields: {
		wxapp_id: {
			validators: {
				notEmpty: {
					message: '平台id不能为空'
	 			},
	 		}
	 	},
		type: {
			validators: {
				notEmpty: {
					message: '轮播图类型不能为空'
	 			},
	 		}
	 	},
		image: {
			validators: {
				notEmpty: {
					message: '图片不能为空'
	 			},
	 		}
	 	},
		createtime: {
			validators: {
				notEmpty: {
					message: '创建时间不能为空'
	 			},
	 		}
	 	},
	 }
}

CodeInfoDlg.collectData = function () {
	this.set('banner_id').set('wxapp_id').set('image').set('createtime').set('route');
};

CodeInfoDlg.add = function () {
	 this.clearData();
	 this.collectData();
	 if (!this.validate()) {
	 	return;
	 }
	 var type = $("input[name = 'type']:checked").val();
	 var ajax = new $ax(Feng.ctxPath + "/ZhBanner/add", function (data) {
	 	if ('00' === data.status) {
	 		Feng.success(data.msg,1000);
	 		window.parent.CodeGoods.table.refresh();
	 		CodeInfoDlg.close();
	 	} else {
	 		Feng.error(data.msg + "！",1000);
		 }
	 })
	 ajax.set('type',type);
	 ajax.set(this.CodeInfoData);
	 ajax.start();
};


</script>
<script src="__PUBLIC__/static/js/base.js" charset="utf-8"></script>
{/block}
